/*
 * Systemprogrammierung
 * Multiplayer-Quiz
 *
 * Gemeinsam verwendete Module
 *
 * rfc.h: Definitionen für das Netzwerkprotokoll gemäß dem RFC
 */

#ifndef RFC_H
#define RFC_H


#define LOGIN_REQUEST 1
#define LOGIN_RESPONSE_OK 2
#define CATALOG_REQUEST 3
#define CATALOG_RESPONSE 4
#define CATALOG_CHANGE 5
#define PLAYER_LIST 6
#define START_GAME 7
#define QUESTION_REQUEST 8
#define QUESTION 9
#define QUESTION_ANSWERED 10
#define QUESTION_RESULT 11
#define GAME_OVER 12
#define ERROR_WARNING 255


#define HEADER_LENGTH 3
#define MAX_PACKET_SIZE 1024


#define WARNING 0
#define FATAL 1


#define RFC_UNKNOWN -1
#define SOCKET_ERROR -2
#define SEND_ERROR -3
#define RECEIVE_ERROR -4
#define COM_ERR -5


#define SERVER_FULL 254
#define NAME_EXISTS 253
#define THREAD_ERROR 252
#define UNKNOWN_ERROR 251
#define NO_USERS 250
#define SPIELLEITER_LEFT 249
#define CLIENT_LEFT 248
#define GAME_RUNNING 247
#define CATALOG_ERROR 246
#define ONLY_ONE 245


# define MAX_USERS 4

/*******Includes*******/

#include "common/question.h"

/*******Strukturen für RFC-Nachrichten*******/

#pragma pack(1)

/** Struktur für RFC-Header
 *  Padding mit #pragma pack(1) verhindert */
struct RFC_HEADER {
	uint8_t type;
	uint16_t length;
};

/** Struktur für RFC-Nachricht
 *  Padding mit #pragma pack(1) verhindert */
struct RFC_MSG {
	struct RFC_HEADER header;
	char data[MAX_PACKET_SIZE];
};

#pragma pack(0)


#endif
